<?php
/**
 * Copyright (C) 2007 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     @license http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @author api.jmatt@gmail.com
 * @version 0.1
 */

require_once('utilities.php');

$inputArray = array('doc' =>  null);
$inputArray['doc'] = array('value' => null);
$inputArray['doc']['value'] = array();
$inputArray['doc']['value']['1'] = 100;
$inputArray['doc']['value']['x'] = array();
$inputArray['doc']['value']['x']['attributes'] = array();
$inputArray['doc']['value']['x']['attributes']['color'] = 'red';
$inputArray['doc']['value']['x']['attributes']['size'] = '14pt';
$inputArray['doc']['value']['x']['attributes']['face'] = 'Times';
$inputArray['doc']['value'][' x'] = 'dup of x';
$inputArray['doc']['value']['z'] = array();
$inputArray['doc']['value']['z']['value'] = array();
$inputArray['doc']['value']['z']['value']['za'] = array();
$inputArray['doc']['value']['z']['value']['za']['value'] = 7;
$inputArray['doc']['value']['z']['value']['za']['attriibutes'] = array();
$inputArray['doc']['value']['z']['value']['za']['attributes']['inside'] = 
  'false';
$inputArray['doc']['value']['z']['value']['zb'] = 18;
$inputArray['doc']['value']['alpha'] = null;

$xml_out = '<doc><1>100</1><x color="red" size="14pt" face="Times"/>' .
           '<x>dup of x</x><z><za inside="false">7</za><zb>18</zb>' .
           '</z></doc>';
if ( assert($xml_out == ArrayToXml($inputArray)) ) {
  echo "Test passed!\n";
} else {
  echo "Test failed!\n";
}
?>
